// 属性相关接口
import request from "@/utils/request";
import type { CategoryResponseData, AttrResponseData,Attr } from './type'

enum API {
  C1_URL = '/admin/product/getCategory1',
  C2_URL = '/admin/product/getCategory2/',
  C3_URL = '/admin/product/getCategory3/',
  ATTR_URL = '/admin/product/attrInfoList/',
  ADDORUPDATEATTR_URL = '/admin/product/saveAttrInfo',
  DELETEATTR_URL = '/admin/product/deleteAttr/'
}
// 一级分类下拉接口
export const reqC1 = () => request.get<any, CategoryResponseData>(API.C1_URL)
// 根据一级分类id获取二级分类下拉接口
export const reqC2 = (category1Id: number | string) => request.get<any, CategoryResponseData>(API.C2_URL + category1Id)
// 根据二级分类id获取三级分类下拉接口
export const reqC3 = (category2Id: number | string) => request.get<any, CategoryResponseData>(API.C3_URL + category2Id)
// 根据一级、二级、三级id获取已有属性和属性值
export const reqAttr = (category1Id: number | string, category2Id: number | string, category3Id: number | string) => {
  return request.get<any, AttrResponseData>(API.ATTR_URL + `${category1Id}/${category2Id}/${category3Id}`)
}
// 添加/修改属性
export const reqAddOrUpdate = (data:Attr) => request.post<any,any>(API.ADDORUPDATEATTR_URL,data)
// 删除属性
export const reqRemoveAttr = (attrId:number) => request.delete<any,any>(API.DELETEATTR_URL+attrId)